1
/****************************** Module Header ******************************\
2 * Module Name: Default.aspx.cs
3 * Project: CSASPNETDragItemInListView
4 * Copyright (c) Microsoft Corporation
6 * The project illustrates how to drag and drop items in ListView using JQuery.
7 * In this page, bind two xml data files to ListView and use ItemTemplate to display
8 * them, cite JQuery javascript library to implements these functions in
11 * This source is subject to the Microsoft Public License.
12 * See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
13 * All other rights reserved.
15 ' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
16 ' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
17 ' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
18 '**************************************************************************/
24 using System
.Web
.UI
.WebControls
;
27 namespace CSASPNETDragItemInListView
29 public partial class Default
: System
.Web
.UI
.Page
31 protected void Page_Load(object sender
, EventArgs e
)
33 // Bind two xml data file to ListView control, actually you can change the "open" property to "0",
34 // In that way, it will not display in ListView control.
35 XmlDocument xmlDocument
= new XmlDocument();
36 using (DataTable tabListView1
= new DataTable())
38 tabListView1
.Columns
.Add("value", Type
.GetType("System.String"));
39 xmlDocument
.Load(AppDomain
.CurrentDomain
.BaseDirectory
+ "/XmlFile/ListView1.xml");
40 XmlNodeList xmlNodeList
= xmlDocument
.SelectNodes("root/data[@open='1']");
41 foreach (XmlNode xmlNode
in xmlNodeList
)
43 DataRow dr
= tabListView1
.NewRow();
44 dr
["value"] = xmlNode
.InnerText
;
45 tabListView1
.Rows
.Add(dr
);
47 ListView1
.DataSource
= tabListView1
;
51 XmlDocument xmlDocument2
= new XmlDocument();
52 using (DataTable tabListView2
= new DataTable())
54 tabListView2
.Columns
.Add("value2", Type
.GetType("System.String"));
55 xmlDocument2
.Load(AppDomain
.CurrentDomain
.BaseDirectory
+ "/XmlFile/ListView2.xml");
56 XmlNodeList xmlNodeList2
= xmlDocument2
.SelectNodes("root/data[@open='1']");
57 foreach (XmlNode xmlNode
in xmlNodeList2
)
59 DataRow dr
= tabListView2
.NewRow();
60 dr
["value2"] = xmlNode
.InnerText
;
61 tabListView2
.Rows
.Add(dr
);
63 ListView2
.DataSource
= tabListView2
;